#encoding:utf8
#Python 2 打印中文字符必须加上上面这一行，否则会报错
# 1.1 小节
# 数值型举例，打印出来的东西回事他们的类名
# 整形
print(type(2))

# 浮点型（小数类型）
print(type(2.3))

# 复数 复数一般由实部和虚部组成，所以中间的+号不是运算符，而是代表复数实部和虚部的结合
print(type(3+3.4444444J))

############ 运算符演示 #####################
print("2+3的值为：")
print(2+3)

print("3-2的值为：")
print(3-2)

print("2*3的值为：")
print(2*3)

print("3/2的值为：")
print(3/2)
print("3.0/2.0的值为：")
print(3.0/2.0)

print("3%2的值为：")
print(3%2)

print("3**2的值为：")
print(3**2)

print("3//2的值为：")
print(3//2)

################# 数值 内置函数演示 #############

import operator

print("3 小于等于2 是否是对的")
operator.le(3,2)

import math

print("4.3取整")
print(math.ceil(4.3))

print("e 的 10 次方")
print(math.exp(10))

print("-10 取绝对值为：")
print(math.fabs(-10))

print("向下取整取4.9")
print(math.floor(4.9))

List = [13,3.5,6,99,4]
print("列表的最小值是")
print(min(List))

Tuple=(13,3.5,6,99,4)
print("元组的最大值是")
print(max(Tuple))

pi = 3.1415926
print("四舍五入")
print(round(pi,3))

print("4的开方")
print(math.sqrt(4))

null = None

########## 字符串

## 特殊字符
# 换行符
# \n \r\n

### 字符串
testStr = "abesteafaewfaewvwe"
print(testStr[5:])
testStr2 = "你好" #  汉字长度*3
print(len(testStr2))

finalStr = testStr + testStr2
print("拼接的字符串"+finalStr)

finalStr1 = testStr +str(1)
print(finalStr1)

print("替换后的testStr")
testStr = testStr.replace("wvwe","去死吧")
print(testStr)

print("分割后的字符串")
splitedStr = testStr.split("f")
print(splitedStr)




## 元祖 有序的
tuple1 = ('a','b','c','d','e','fg')
print(tuple1[1])
print("元组长度")
print(len(tuple1))
print(tuple1[2:])


## 列表 有序的

list1 = ["2","3","4"]
print(list1)
print(list1)



## 字典
dict = {
    "zhoudandan":"周丹丹"
}
print(dict)
print(dict["zhoudandan"])
# print(dict.has_key(""))
print(dict)
dict["tangfangfang"]="唐芳芳"
print(dict)

# 有序的字典叫做sorted dict


####################### 执行流程


if True:
    print("ok")
elif False:
    print("肯定不执行啊")

forLength = 6
for i in range(6):
    print(i)

print("_____________我是可爱的分隔符————————————————")
for i in range(len(tuple1)):
    print(tuple1[i])

tiaojian = 6

while tiaojian>0 :
    print(tiaojian)
    tiaojian = tiaojian - 1


def shangtianba():
    pass # 占位符
    # TODO 我们需要干一些上天的事情

def bushangtianl(canshu):
    print(canshu)


bushangtianl("去吧")
# bushangtianl() 会报错


def bushangtianl(canshu = None):
    print(canshu)

bushangtianl()

def paochucuowu():
    raise Exception("我错了")



try:
    print("xxx")
    # paochucuowu()
except Exception as e:
    print(e)
finally:
    print("无论是否出错，我都会出现")

print("抛出错误被补货后的执行")

class class1():

    def __init__(self,chuancan1):
        print(chuancan1)
        pass


# 使用类

class1Use = class1("好了，我给参数了") # 实例化



class class2():

    def __init__(self,chuancan1 = None):
        # self.chengyuan1 = chuancan1
        # print(chuancan1)
        pass

    def fuzhi(self,chengyuanyi):
        self.chengyuan1 = chengyuanyi

    def dayin(self):
        print(self.chengyuan1)

    class subClass():
        woshichengyuana = 0

        def caozuo(self):
            self.woshichengyuana = 3


classUser2 = class2()
classUser2.fuzhi("我们赋值了")
classUser2.dayin()




class class3(class2):
    def __init__(self):
        class2.__init__() # 必须带继承的类名字来init
        pass



class3Use = class3()
class3Use.fuzhi("调用")



























